package main

import (
	"income/utils"
	"sync"
)

func main() {
	var table utils.Table
	lists := utils.GetTableList()
	wg := &sync.WaitGroup{}
	for _, table = range lists {
		wg.Add(1)
		go execute(table,wg)
	}
	wg.Wait()
}

func execute(t utils.Table,wg *sync.WaitGroup) {
	content := utils.Template(t)
	to := t.Employee.Name + "<" + t.Employee.Email + ">"
	subject := t.Company + t.WorkMonth + "工资表"
	utils.SendEmail(to, subject, content, true)
	defer wg.Done()
}
